Expand description

Bevy plugin offering generic asset loaders for common file formats

This library includes a collection of thin wrapper plugins around serde implementations for the common file formats json, ron, toml, yaml, MessagePack and xml. Each plugin adds an asset loader for a user type. Assets of that type will then be loaded from all files with configurable extensions.

The following example requires the json feature and loads a custom asset from a json file.

use bevy::prelude::*;
use bevy::reflect::TypePath;
use bevy_common_assets::json::JsonAssetPlugin;

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, JsonAssetPlugin::<Level>::new(&["level.json"])))
        .add_systems(Startup, load_level)
        .run()
}

fn load_level(mut commands: Commands, asset_server: Res<AssetServer>) {
    let handle = LevelAsset(asset_server.load("trees.level.json"));
    commands.insert_resource(handle);
}

#[derive(serde::Deserialize, Asset, TypePath)]
struct Level {
    positions: Vec<[f32; 3]>,
}

#[derive(Resource)]
struct LevelAsset(Handle<Level>);

Modules§

  • csvcsv
    Module containing a Bevy plugin to load assets from csv files with custom file extensions.
  • jsonjson
    Module containing a Bevy plugin to load assets from json files with custom file extensions.
  • msgpackmsgpack
    Module containing a Bevy plugin to load assets from MassagePack files with custom file extensions.
  • ronron
    Module containing a Bevy plugin to load assets from ron files with custom file extensions.
  • tomltoml
    Module containing a Bevy plugin to load assets from toml files with custom file extensions.
  • xmlxml
    Module containing a Bevy plugin to load assets from xml files with custom file extensions.
  • yamlyaml
    Module containing a Bevy plugin to load assets from yaml files with custom file extensions.